package com.lzx.controller;

import com.lzx.model.FileEntity;
import com.lzx.model.wlwjd.Wlwjd;
import com.lzx.service.FileEntityService;
import com.lzx.service.wlwjd.WlwjdService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.servlet.ModelAndView;

import java.util.List;

@RestController
@RequestMapping("/wlwjd")
public class WlwjdController{
    @Autowired
    private WlwjdService wlwjdService;
    @Autowired
    private FileEntityService fileEntityService;

    @RequestMapping("/wlwjd.html")
    public ModelAndView wlwjd(){
        ModelAndView mv  = new ModelAndView("system/wlwjd");
        String position = "哈尔滨";
        Wlwjd wlwjd = wlwjdService.findByPosition(position);
        String detailed = wlwjd.getDetailed();
        List<FileEntity> listfile = fileEntityService.findByYwId(wlwjd.getPhotoid());
        String url="";
        for (int i = 0; i <listfile.size() ; i++) {
            url=listfile.get(i).getUrlPath();
        }
        mv.addObject("url",url);
        mv.addObject("detailed",detailed);
        return mv;
    }
}
